package com.jutou.wap.jdbc;

import java.sql.Connection;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.druid.pool.DruidPooledConnection;

public class JdbcConnection {
	@Autowired
	private SqlSessionFactory sqlSessionFactory;

	public Connection getConnection() {
	 SqlSession sqlSession = sqlSessionFactory.openSession();
		DruidPooledConnection conn = null;
		try {
			conn = (DruidPooledConnection) sqlSession.getConfiguration().getEnvironment().getDataSource()
					.getConnection();
			sqlSession.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return conn;
	}

}
